<?php
/* @var $this NewsController */
/* @var $dataProvider CActiveDataProvider */

$this->breadcrumbs=array(
	'News',
);

$this->menu=array(
	array('label'=>'Create News', 'url'=>array('create')),
	array('label'=>'Manage News', 'url'=>array('admin')),
);
?>

<div class="row">
    <div class="page-header">
        <h1>Управление новостями</h1>
    </div>
</div>
<?php $data = $dataProvider->getData(); ?>
<?php if (isset($message)): ?>
    <div class="row alert alert-success">
        <?php echo $message; ?>
    </div>
<?php endif; ?>
<div class="row">
    <table class="table table-hover table-bordered table-striped">
        <thead>
        <tr>
            <th>Заголовок новости</th>
            <th>Дата создания</th>
            <th>Отображать</th>
            <th>Управление новостью</th>
        </tr>
        </thead>
        <tbody>
        <?php foreach($data as $news):?>
            <tr>
                <td><?php echo $news->title; ?></td>
                <td><?php echo $news->created_at; ?></td>
                <td><?php echo ($news->is_visible == 1 ? "Да" : "Нет"); ?></td>
                <td>
                    <?php echo CHtml::link('<span class="glyphicon glyphicon-pencil"></span>', array($this->createUrl('/obnovit/novost', array('id'=>$news->id))), array('class' => 'btn-sm btn-warning')); ?>
                    <?php echo CHtml::link('<span class="glyphicon glyphicon-remove"></span>', "#", array(
                        'submit'=>array('/udalit/novost', 'id'=>$news->id),
                        'class' => 'btn-sm btn-danger',
                        'confirm' => 'Вы действительно хотите удалить новость "'.$news->title.'"?',
                        'csrf' => true)); ?>
                </td>
            </tr>
        <?php endforeach; ?>
        </tbody>
    </table>
</div>
<div class="row buttons">
    <?php echo CHtml::link('Добавить', array($this->createUrl('/dobavit/novost')), array('class' => 'btn btn-info')); ?>
</div>
<div class="row">
    <?$this->widget('CLinkPager', array(
        'pages' => $dataProvider->getPagination(),
        'htmlOptions' => array('class'=>'pagination'),
        'selectedPageCssClass' => 'active',
        'header' => '',
        'nextPageLabel' => 'След.',
        'lastPageLabel' => '&raquo;',
        'firstPageLabel' => '&laquo;',
        'prevPageLabel' => 'Пред.'
    ))?>
</div>
